idle_loop: either deal with tasklets or go idle
authorDario Faggioli <dario.faggioli@citrix.com>
Thu, 22 Jun 2017 07:45:37 +0000 (09:45 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 22 Jun 2017 07:45:37 +0000 (09:45 +0200)
commit4463e7b980fdcf5076c8f939542a1c21738af782
tree864ed726048a3dfeb6960c92dd3e6fecee8f8d03
parentded7303f161fd578f0ac9fbaf52cfd9d72b4a320
idle_loop: either deal with tasklets or go idle

In fact, there are two kinds of tasklets: vCPU and
softirq context. When we want to do vCPU context tasklet
work, we force the idle vCPU (of a particular pCPU) into
execution, and run it from there.

This means there are two possible reasons for choosing
to run the idle vCPU:
1) we want a pCPU to go idle,
2) we want to run some vCPU context tasklet work.

If we're in case 2), it does not make sense to even
try to go idle (as the check will _always_ fail).

This patch rearranges the code of the body of idle
vCPUs, so that we actually check whether we are in
case 1) or 2), and act accordingly.

As a matter of fact, this also means that we do not
check if there's any tasklet work to do after waking
up from idle. This is not a problem, because:
a) for softirq context tasklets, if any is queued
   "during" wakeup from idle, TASKLET_SOFTIRQ is
   raised, and the call to do_softirq() (which is still
   happening *after* the wakeup) will take care of it;
b) for vCPU context tasklets, if any is queued "during"
   wakeup from idle, SCHEDULE_SOFTIRQ is raised and
   do_softirq() (happening after the wakeup) calls
   the scheduler. The scheduler sees that there is
   tasklet work pending and confirms the idle vCPU
   in execution, which then will get to execute
   do_tasklet().

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/domain.c
xen/arch/x86/domain.c
xen/common/tasklet.c
xen/include/xen/sched.h
xen/include/xen/tasklet.h